package com.example.springcloud.springcloudfeign.controller;

import com.example.springcloud.springcloudfeign.User;
import com.example.springcloud.springcloudfeign.feign.FeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试定义的FeignService控制器
 * weiximei on 2018/6/10
 */
@RestController
public class ConsumerController {


    /**
     * 把定义好的FeignService接口注入进来
     */
    @Autowired
    FeignService feignService;

    /**
     * 此时调用这个控制器的时候，可以同时调用远程的hello-service
     * @return
     */
    @RequestMapping("/helloConsumer")
    public String helloConsumer(){
        return feignService.hello();
    }


    /**
     * 请求带参数的
     * @return
     */
    @RequestMapping("/helloConsumer2")
    public String helloConsumer2(){
        String r1 = feignService.hello("weiximei");
        String r2 = feignService.hello("weiximei",21).toString();
        String r3 = feignService.hello(new User());

        return r1+"--"+r2+"--"+r3;

    }





}
